package com.cndw.kungfu.model.pvp.api;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.cndw.kungfu.ext.LogUtil;
import com.cndw.kungfu.model.activity.holiday.MMFlowerLog;
import com.cndw.kungfu.model.activity.holiday.MMFlowerPlayer;
import com.cndw.rpg.framework.ResponseMessage;

public class FlowerApiClient {
	
	
	public static void addFlowerLog(MMFlowerLog log) {
		ApiClient.setdApi(ApiCore.crossSid(), ApiConfig.mmFlowerCross, log);
	}
	
	public static ResponseMessage mmFlowerTop(){
		return ApiClient.apiMessage(ApiCore.crossSid(), ApiConfig.mmFlowerTop, 3000);
	}
	
	
	public static ResponseMessage getFlowerLog() {
		return ApiClient.apiMessage(ApiCore.crossSid(), ApiConfig.mmFlowerLog, 3000);
	}
	
	public static void sendAward(int orderId, long pid,int sid) {
		 ApiClient.apiMessage(sid, ApiConfig.mmFlowerAward, 3000, pid, orderId);
	}
	
	
	
	
	@SuppressWarnings("unchecked")
	public static Collection<MMFlowerPlayer> mmflowerPlayer(int sid){
		
		Object message = ApiClient.setdApi(sid, ApiConfig.mmFlowerPlayer);
		if (message == null) {
			LogUtil.getMain().debug("err warFighters null " + sid);
			return null;
		}
		if (message.getClass().isArray()) {
			List<MMFlowerPlayer> allPlayers = new ArrayList<MMFlowerPlayer>();
			Object[] pArray = (Object[]) message;
			for (Object warPlayer : pArray) {
				allPlayers.add((MMFlowerPlayer) warPlayer);
			}
			return allPlayers;
		} else {
			return (Collection<MMFlowerPlayer>) message;
		}
		
	}

}
